package com.galaxy.order.controller;

import com.galaxy.order.domain.OrderStatusLog;
import com.galaxy.order.service.OrderStatusLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order-status-log")
public class OrderStatusLogController {
    @Autowired
    private OrderStatusLogService orderStatusLogService;

    @PostMapping
    public OrderStatusLog create(@RequestBody OrderStatusLog orderStatusLog) {
        orderStatusLogService.save(orderStatusLog);
        return orderStatusLog;
    }

    @PutMapping
    public OrderStatusLog update(@RequestBody OrderStatusLog orderStatusLog) {
        orderStatusLogService.updateById(orderStatusLog);
        return orderStatusLog;
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Long id) {
        return orderStatusLogService.removeById(id);
    }

    @GetMapping("/{id}")
    public OrderStatusLog getById(@PathVariable Long id) {
        return orderStatusLogService.getById(id);
    }
}
